package com.tehui.view;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.HorizontalScrollView;

/**
 * Created by jasmine on 2017/7/14.
 */

public class CustomeUserNoticeScrollView extends HorizontalScrollView {
    CustomeUserNoticeCursor cursor;
    private float   noticeScrollViewTotleWidth;
    private float   noticeScrollViewVisibleWidth;
    private Context context;

    public CustomeUserNoticeScrollView(Context context) {
        this(context, null);
    }

    public CustomeUserNoticeScrollView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        this.context = context;

    }

    public CustomeUserNoticeScrollView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        noticeScrollViewTotleWidth = this.getChildAt(0).getMeasuredWidth();
        noticeScrollViewVisibleWidth = this.getWidth();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        float currentScrollX = this.getScrollX();
        cursor.SetOffSet(currentScrollX);
    }

    public void setCursor(CustomeUserNoticeCursor user_notice_cursor) {
        this.cursor = user_notice_cursor;
    }
}
